/**
 * Copyright (C) 2014 Luvina Software Company
 * MessageProperties.java, Dec 15, 2014, Nguyen Huu Luan LA11_AM
 *
 */

package net.luvina.manageuser.utils;

import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Đọc thông tin các thông báo lỗi được thiết định sẵn trong file
 * message_error_ja.properties.
 * 
 * @author luan
 * 
 */
@SuppressWarnings("unchecked")
public class MessageErrorProperties {
	static private Map<String, String> data = new HashMap<String, String>();

	/**
     *
     */
	static {
		Properties prop = new Properties();
		try {
			prop.load(MessageErrorProperties.class
					.getResourceAsStream(("/message_error_ja.properties")));
		} catch (IOException e) {
			e.printStackTrace();
		}

		Enumeration<String> en = (Enumeration<String>) prop.propertyNames();
		while (en.hasMoreElements()) {
			String key = (String) en.nextElement();
			data.put(key, prop.getProperty(key));
		}
	}

	/**
	 * Lấy thông tin message từ properties file.
	 * 
	 * @param key
	 *            key
	 * @return String
	 */
	static public String getMessage(String key) {
		String string = "";
		if (data.containsKey(key)) {
			string = data.get(key);
		}
		return string;
	}
}
